package wh.two;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class InputNumberFromKey {
		
	public void getInput() {
		
		File f=new File("numinput.txt");
		try {
			Scanner sc=new Scanner(f);
			int filelength=0;
			
			//9-16version1
			
			  while(sc.hasNext()) { 
				  filelength++; 
				  } 
			  int[] myinput = new int[filelength];
			  
			  System.out.println("ddddd"+filelength);
			 
			
			
			  int i = 0; 
			  while(sc.hasNext()) {
			  
			  myinput[i]=sc.nextInt(); i++;
			  
			  
			  } 
			  Arrays.sort(myinput); 
			/*
			 * for(i=0;i<myinput.length;i++) { System.out.println(myinput[i]); }
			 */
			  //foreach
			  for(int l:myinput) {
				  System.out.println(l);
			  }
			 
			sc.close();
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
	}

	public void getInputtoList() {
		ArrayList<Integer> ar=new ArrayList<Integer>();
		File f=new File("numinput.txt");
		Scanner sc;
		try {
			sc = new Scanner(f);
			while(sc.hasNext()) {
				ar.add(sc.nextInt());
		    }//end of while
			//sort list
			Collections.sort(ar);
			//for
			/*
			 * for(int i=0;i<ar.size();i++) { System.out.println(ar.get(i)); }
			 */
			for(int k:ar) {
				System.out.println(k);
			}
			
		
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		
	}
}

